package com.novel.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.novel.mapper.ScoreMapper;
import com.novel.service.ScoreService;
import com.reading.pojo.NovelScore;
import com.reading.pojo.NovelScoreUser;
import com.reading.pojo.Score;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ScoerServiceImpl implements ScoreService {

    @Resource
    private ScoreMapper scoreMapper;

    @Override
    public Score list(Integer pid) {
        return scoreMapper.list(pid);
    }

    @Override
    public List<NovelScore> findbyid(Integer pid) {
        return scoreMapper.findbyid(pid);
    }

    @Override
    public List<NovelScore> findall(Integer pid) {
        return scoreMapper.findall(pid);
    }

    @Override
    public List<Score> findAllScore() {
        return scoreMapper.findAllScore();
    }

    @Override
    public PageInfo findcomment(NovelScore novelScore, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<NovelScore> list = scoreMapper.findcomment(novelScore);

        PageInfo pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int add(NovelScore novelScore) {
        novelScore.setCommenttime(String.valueOf(LocalDateTime.now()));
        return scoreMapper.add(novelScore);
    }

    @Override
    public NovelScoreUser findid(Integer id) {
        return scoreMapper.findid(id);
    }

    @Override
    public List<NovelScoreUser> findalluser(Integer uid) {
        return scoreMapper.findalluser(uid);
    }

    @Override
    public void delete(Integer id) {
        scoreMapper.delete(id);
    }


}
